home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / a2.0bemacs-src.lha / Emacs-19.25 / src / lread.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-22  |  50.5 KB  |  2,021 lines

  1. /* Lisp parsing and input streams.
  2.    Copyright (C) 1985, 1986, 1987, 1988, 1989, 
  3.    1993, 1994 Free Software Foundation, Inc.
  4.  
  5. This file is part of GNU Emacs.
  6.  
  7. GNU Emacs is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU Emacs is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU Emacs; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. #include <stdio.h>
  23. #include <sys/types.h>
  24. #include <sys/stat.h>
  25. #include <sys/file.h>
  26. #include <ctype.h>
  27. #include <config.h>
  28. #include "lisp.h"
  29.  
  30. #ifndef standalone
  31. #include "buffer.h"
  32. #include <paths.h>
  33. #include "commands.h"
  34. #include "keyboard.h"
  35. #include "termhooks.h"
  36. #endif
  37.  
  38. #ifdef lint
  39. #include <sys/inode.h>
  40. #endif /* lint */
  41.  
  42. #ifndef X_OK
  43. #define X_OK 01
  44. #endif
  45.  
  46. #ifdef LISP_FLOAT_TYPE
  47. #ifdef STDC_HEADERS
  48. #ifdef AMIGA /* CHFIXME */
  49. #undef abort
  50. #endif
  51. #include <stdlib.h>
  52. #endif
  53.  
  54. #ifdef MSDOS
  55. /* These are redefined (correctly, but differently) in values.h.  */
  56. #undef INTBITS
  57. #undef LONGBITS
  58. #undef SHORTBITS
  59. #endif
  60.  
  61. #include <math.h>
  62. #endif /* LISP_FLOAT_TYPE */
  63.  
  64. #ifdef USE_PROTOS
  65. #include "protos.h"
  66. #endif
  67.  
  68. Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list;
  69. Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
  70. Lisp_Object Qascii_character, Qload;
  71.  
  72. extern Lisp_Object Qevent_symbol_element_mask;
  73.  
  74. /* non-zero if inside `load' */
  75. int load_in_progress;
  76.  
  77. /* Search path for files to be loaded. */
  78. Lisp_Object Vload_path;
  79.  
  80. /* This is the user-visible association list that maps features to
  81.    lists of defs in their load files. */
  82. Lisp_Object Vload_history;
  83.  
  84. /* This is useud to build the load history. */
  85. Lisp_Object Vcurrent_load_list;
  86.  
  87. /* List of descriptors now open for Fload.  */
  88. static Lisp_Object load_descriptor_list;
  89.  
  90. /* File for get_file_char to read from.  Use by load */
  91. static FILE *instream;
  92.  
  93. /* When nonzero, read conses in pure space */
  94. static int read_pure;
  95.  
  96. /* For use within read-from-string (this reader is non-reentrant!!) */
  97. static int read_from_string_index;
  98. static int read_from_string_limit;
  99.  
  100. /* Handle unreading and rereading of characters.
  101.    Write READCHAR to read a character,
  102.    UNREAD(c) to unread c to be read again. */
  103.  
  104. #define READCHAR readchar (readcharfun)
  105. #define UNREAD(c) unreadchar (readcharfun, c)
  106.  
  107. static int
  108. readchar (readcharfun)
  109.      Lisp_Object readcharfun;
  110. {
  111.   Lisp_Object tem;
  112.   register struct buffer *inbuffer;
  113.   register int c, mpos;
  114.  
  115.   if (XTYPE (readcharfun) == Lisp_Buffer)
  116.     {
  117.       inbuffer = XBUFFER (readcharfun);
  118.  
  119.       if (BUF_PT (inbuffer) >= BUF_ZV (inbuffer))
  120.     return -1;
  121.       c = *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer, BUF_PT (inbuffer));
  122.       SET_BUF_PT (inbuffer, BUF_PT (inbuffer) + 1);
  123.  
  124.       return c;
  125.     }
  126.   if (XTYPE (readcharfun) == Lisp_Marker)
  127.     {
  128.       inbuffer = XMARKER (readcharfun)->buffer;
  129.  
  130.       mpos = marker_position (readcharfun);
  131.  
  132.       if (mpos > BUF_ZV (inbuffer) - 1)
  133.     return -1;
  134.       c = *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer, mpos);
  135.       if (mpos != BUF_GPT (inbuffer))
  136.     XMARKER (readcharfun)->bufpos++;
  137.       else
  138.     Fset_marker (readcharfun, make_number (mpos + 1),
  139.              Fmarker_buffer (readcharfun));
  140.       return c;
  141.     }
  142.   if (EQ (readcharfun, Qget_file_char))
  143.     return getc (instream);
  144.  
  145.   if (XTYPE (readcharfun) == Lisp_String)
  146.     {
  147.       register int c;
  148.       /* This used to be return of a conditional expression,
  149.      but that truncated -1 to a char on VMS.  */
  150.       if (read_from_string_index < read_from_string_limit)
  151.     c = XSTRING (readcharfun)->data[read_from_string_index++];
  152.       else
  153.     c = -1;
  154.       return c;
  155.     }
  156.  
  157.   tem = call0 (readcharfun);
  158.  
  159.   if (NILP (tem))
  160.     return -1;
  161.   return XINT (tem);
  162. }
  163.  
  164. /* Unread the character C in the way appropriate for the stream READCHARFUN.
  165.    If the stream is a user function, call it with the char as argument.  */
  166.  
  167. static void
  168. unreadchar (readcharfun, c)
  169.      Lisp_Object readcharfun;
  170.      int c;
  171. {
  172.   if (c == -1)
  173.     /* Don't back up the pointer if we're unreading the end-of-input mark,
  174.        since readchar didn't advance it when we read it.  */
  175.     ;
  176.   else if (XTYPE (readcharfun) == Lisp_Buffer)
  177.     {
  178.       if (XBUFFER (readcharfun) == current_buffer)
  179.     SET_PT (point - 1);
  180.       else
  181.     SET_BUF_PT (XBUFFER (readcharfun), BUF_PT (XBUFFER (readcharfun)) - 1);
  182.     }
  183.   else if (XTYPE (readcharfun) == Lisp_Marker)
  184.     XMARKER (readcharfun)->bufpos--;
  185.   else if (XTYPE (readcharfun) == Lisp_String)
  186.     read_from_string_index--;
  187.   else if (EQ (readcharfun, Qget_file_char))
  188.     ungetc (c, instream);
  189.   else
  190.     call1 (readcharfun, make_number (c));
  191. }
  192.  
  193. static Lisp_Object read0 (), read1 (), read_list (), read_vector ();
  194.  
  195. /* get a character from the tty */
  196.  
  197. extern Lisp_Object read_char ();
  198.  
  199. /* Read input events until we get one that's acceptable for our purposes.
  200.  
  201.    If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed
  202.    until we get a character we like, and then stuffed into
  203.    unread_switch_frame.
  204.  
  205.    If ASCII_REQUIRED is non-zero, we check function key events to see
  206.    if the unmodified version of the symbol has a Qascii_character
  207.    property, and use that character, if present.
  208.  
  209.    If ERROR_NONASCII is non-zero, we signal an error if the input we
  210.    get isn't an ASCII character with modifiers.  If it's zero but
  211.    ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII
  212.    character.  */
  213. Lisp_Object
  214. read_filtered_event (no_switch_frame, ascii_required, error_nonascii)
  215.      int no_switch_frame, ascii_required, error_nonascii;
  216. {
  217. #ifdef standalone
  218.   return make_number (getchar ());
  219. #else
  220.   register Lisp_Object val, delayed_switch_frame;
  221.  
  222.   delayed_switch_frame = Qnil;
  223.  
  224.   /* Read until we get an acceptable event.  */
  225.  retry:
  226.   val = read_char (0, 0, 0, Qnil, 0);
  227.  
  228.   if (XTYPE (val) == Lisp_Buffer)
  229.     goto retry;
  230.  
  231.   /* switch-frame events are put off until after the next ASCII
  232.      character.  This is better than signalling an error just because
  233.      the last characters were typed to a separate minibuffer frame,
  234.      for example.  Eventually, some code which can deal with
  235.      switch-frame events will read it and process it.  */
  236.   if (no_switch_frame
  237.       && EVENT_HAS_PARAMETERS (val)
  238.       && EQ (EVENT_HEAD (val), Qswitch_frame))
  239.     {
  240.       delayed_switch_frame = val;
  241.       goto retry;
  242.     }
  243.  
  244.   if (ascii_required)
  245.     {
  246.       /* Convert certain symbols to their ASCII equivalents.  */
  247.       if (XTYPE (val) == Lisp_Symbol)
  248.     {
  249.       Lisp_Object tem, tem1, tem2;
  250.       tem = Fget (val, Qevent_symbol_element_mask);
  251.       if (!NILP (tem))
  252.         {
  253.           tem1 = Fget (Fcar (tem), Qascii_character);
  254.           /* Merge this symbol's modifier bits
  255.          with the ASCII equivalent of its basic code.  */
  256.           if (!NILP (tem1))
  257.         XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem)));
  258.         }
  259.     }
  260.       
  261.       /* If we don't have a character now, deal with it appropriately.  */
  262.       if (XTYPE (val) != Lisp_Int)
  263.     {
  264.       if (error_nonascii)
  265.         {
  266.           Vunread_command_events = Fcons (val, Qnil);
  267.           error ("Non-character input-event");
  268.         }
  269.       else
  270.         goto retry;
  271.     }
  272.     }
  273.  
  274.   if (! NILP (delayed_switch_frame))
  275.     unread_switch_frame = delayed_switch_frame;
  276.  
  277.   return val;
  278. #endif
  279. }
  280.  
  281. DEFUN ("read-char", Fread_char, Sread_char, 0, 0, 0,
  282.   "Read a character from the command input (keyboard or macro).\n\
  283. It is returned as a number.\n\
  284. If the user generates an event which is not a character (i.e. a mouse\n\
  285. click or function key event), `read-char' signals an error.  As an\n\
  286. exception, switch-frame events are put off until non-ASCII events can\n\
  287. be read.\n\
  288. If you want to read non-character events, or ignore them, call\n\
  289. `read-event' or `read-char-exclusive' instead.")
  290.   ()
  291. {
  292.   return read_filtered_event (1, 1, 1);
  293. }
  294.  
  295. DEFUN ("read-event", Fread_event, Sread_event, 0, 0, 0,
  296.   "Read an event object from the input stream.")
  297.   ()
  298. {
  299.   return read_filtered_event (0, 0, 0);
  300. }
  301.  
  302. DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 0, 0,
  303.   "Read a character from the command input (keyboard or macro).\n\
  304. It is returned as a number.  Non character events are ignored.")
  305.   ()
  306. {
  307.   return read_filtered_event (1, 1, 0);
  308. }
  309.  
  310. DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
  311.   "Don't use this yourself.")
  312.   ()
  313. {
  314.   register Lisp_Object val;
  315.   XSET (val, Lisp_Int, getc (instream));
  316.   return val;
  317. }
  318.  
  319. static void readevalloop ();
  320. static Lisp_Object load_unwind ();
  321. static Lisp_Object load_descriptor_unwind ();
  322.  
  323. DEFUN ("load", Fload, Sload, 1, 4, 0,
  324.   "Execute a file of Lisp code named FILE.\n\
  325. First try FILE with `.elc' appended, then try with `.el',\n\
  326.  then try FILE unmodified.\n\
  327. This function searches the directories in `load-path'.\n\
  328. If optional second arg NOERROR is non-nil,\n\
  329.  report no error if FILE doesn't exist.\n\
  330. Print messages at start and end of loading unless\n\
  331.  optional third arg NOMESSAGE is non-nil.\n\
  332. If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
  333.  suffixes `.elc' or `.el' to the specified name FILE.\n\
  334. Return t if file exists.")
  335.   (str, noerror, nomessage, nosuffix)
  336.      Lisp_Object str, noerror, nomessage, nosuffix;
  337. {
  338.   register FILE *stream;
  339.   register int fd = -1;
  340.   register Lisp_Object lispstream;
  341.   register FILE **ptr;
  342.   int count = specpdl_ptr - specpdl;
  343.   Lisp_Object temp;
  344.   struct gcpro gcpro1;
  345.   Lisp_Object found;
  346.   /* 1 means inhibit the message at the beginning.  */
  347.   int nomessage1 = 0;
  348.   Lisp_Object handler;
  349. #ifdef MSDOS
  350.   char *dosmode = "rt";
  351. #endif
  352.  
  353.   CHECK_STRING (str, 0);
  354.   str = Fsubstitute_in_file_name (str);
  355.  
  356.   /* If file name is magic, call the handler.  */
  357.   handler = Ffind_file_name_handler (str, Qload);
  358.   if (!NILP (handler))
  359.     return call5 (handler, Qload, str, noerror, nomessage, nosuffix);
  360.  
  361.   /* Avoid weird lossage with null string as arg,
  362.      since it would try to load a directory as a Lisp file */
  363.   if (XSTRING (str)->size > 0)
  364.     {
  365.       GCPRO1 (str);
  366.       fd = openp (Vload_path, str, !NILP (nosuffix) ? "" : ".elc:.el:",
  367.           &found, 0);
  368.       UNGCPRO;
  369.     }
  370.  
  371.   if (fd < 0)
  372.     {
  373.       if (NILP (noerror))
  374.     while (1)
  375.       Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"),
  376.                        Fcons (str, Qnil)));
  377.       else
  378.     return Qnil;
  379.     }
  380.  
  381.   if (!bcmp (&(XSTRING (found)->data[XSTRING (found)->size - 4]),
  382.          ".elc", 4))
  383.     {
  384.       struct stat s1, s2;
  385.       int result;
  386.  
  387. #ifdef MSDOS
  388.       dosmode = "rb";
  389. #endif
  390.       stat ((char *)XSTRING (found)->data, &s1);
  391.       XSTRING (found)->data[XSTRING (found)->size - 1] = 0;
  392.       result = stat ((char *)XSTRING (found)->data, &s2);
  393.       if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
  394.     {
  395.       message ("Source file `%s' newer than byte-compiled file",
  396.            XSTRING (found)->data);
  397.       /* Don't immediately overwrite this message.  */
  398.       if (!noninteractive)
  399.         nomessage1 = 1;
  400.     }
  401.       XSTRING (found)->data[XSTRING (found)->size - 1] = 'c';
  402.     }
  403.  
  404. #ifdef MSDOS
  405.   close (fd);
  406.   stream = fopen ((char *) XSTRING (found)->data, dosmode);
  407. #else
  408.   stream = fdopen (fd, "r");
  409. #endif
  410.   if (stream == 0)
  411.     {
  412.       close (fd);
  413.       error ("Failure to create stdio stream for %s", XSTRING (str)->data);
  414.     }
  415.  
  416.   if (NILP (nomessage) && !nomessage1)
  417.     message ("Loading %s...", XSTRING (str)->data);
  418.  
  419.   GCPRO1 (str);
  420.   /* We may not be able to store STREAM itself as a Lisp_Object pointer
  421.      since that is guaranteed to work only for data that has been malloc'd.
  422.      So malloc a full-size pointer, and record the address of that pointer.  */
  423.   ptr = (FILE **) xmalloc (sizeof (FILE *));
  424.   *ptr = stream;
  425.   XSET (lispstream, Lisp_Internal_Stream, (int) ptr);
  426.   record_unwind_protect (load_unwind, lispstream);
  427.   record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
  428.   load_descriptor_list
  429.     = Fcons (make_number (fileno (stream)), load_descriptor_list);
  430.   load_in_progress++;
  431.   readevalloop (Qget_file_char, stream, str, Feval, 0);
  432.   unbind_to (count, Qnil);
  433.  
  434.   /* Run any load-hooks for this file.  */
  435.   temp = Fassoc (str, Vafter_load_alist);
  436.   if (!NILP (temp))
  437.     Fprogn (Fcdr (temp));
  438.   UNGCPRO;
  439.  
  440.   if (!noninteractive && NILP (nomessage))
  441.     message ("Loading %s...done", XSTRING (str)->data);
  442.   return Qt;
  443. }
  444.  
  445. static Lisp_Object
  446. load_unwind (stream)  /* used as unwind-protect function in load */
  447.      Lisp_Object stream;
  448. {
  449.   fclose (*(FILE **) XSTRING (stream));
  450.   xfree (XPNTR (stream));
  451.   if (--load_in_progress < 0) load_in_progress = 0;
  452.   return Qnil;
  453. }
  454.  
  455. static Lisp_Object
  456. load_descriptor_unwind (oldlist)
  457.      Lisp_Object oldlist;
  458. {
  459.   load_descriptor_list = oldlist;
  460. }
  461.  
  462. /* Close all descriptors in use for Floads.
  463.    This is used when starting a subprocess.  */
  464.  
  465. void
  466. close_load_descs ()
  467. {
  468.   Lisp_Object tail;
  469.   for (tail = load_descriptor_list; !NILP (tail); tail = XCONS (tail)->cdr)
  470.     close (XFASTINT (XCONS (tail)->car));
  471. }
  472.  
  473. static int
  474. complete_filename_p (pathname)
  475.      Lisp_Object pathname;
  476. {
  477.   register unsigned char *s = XSTRING (pathname)->data;
  478. #ifdef AMIGA
  479.   return (*s && index(s + 1, ':')); /* Non-leading : */
  480. #else
  481.   return (*s == '/'
  482. #ifdef ALTOS
  483.       || *s == '@'
  484. #endif
  485. #ifdef VMS
  486.       || index (s, ':')
  487. #endif /* VMS */
  488. #ifdef MSDOS    /* MW, May 1993 */
  489.       || (s[0] != '\0' && s[1] == ':' && s[2] == '/')
  490. #endif
  491.       );
  492. #endif /* not AMIGA */
  493. }
  494.  
  495. /* Search for a file whose name is STR, looking in directories
  496.    in the Lisp list PATH, and trying suffixes from SUFFIX.
  497.    SUFFIX is a string containing possible suffixes separated by colons.
  498.    On success, returns a file descriptor.  On failure, returns -1.
  499.  
  500.    EXEC_ONLY nonzero means don't open the files,
  501.    just look for one that is executable.  In this case,
  502.    returns 1 on success.
  503.  
  504.    If STOREPTR is nonzero, it points to a slot where the name of
  505.    the file actually found should be stored as a Lisp string.
  506.    Nil is stored there on failure.  */
  507.  
  508. int
  509. openp (path, str, suffix, storeptr, exec_only)
  510.      Lisp_Object path, str;
  511.      char *suffix;
  512.      Lisp_Object *storeptr;
  513.      int exec_only;
  514. {
  515.   register int fd;
  516.   int fn_size = 100;
  517.   char buf[100];
  518.   register char *fn = buf;
  519.   int absolute = 0;
  520.   int want_size;
  521.   register Lisp_Object filename;
  522.   struct stat st;
  523.   struct gcpro gcpro1;
  524.  
  525.   GCPRO1 (str);
  526.   if (storeptr)
  527.     *storeptr = Qnil;
  528.  
  529.   if (complete_filename_p (str))
  530.     absolute = 1;
  531.  
  532.   for (; !NILP (path); path = Fcdr (path))
  533.     {
  534.       char *nsuffix;
  535.  
  536.       filename = Fexpand_file_name (str, Fcar (path));
  537.       if (!complete_filename_p (filename))
  538.     /* If there are non-absolute elts in PATH (eg ".") */
  539.     /* Of course, this could conceivably lose if luser sets
  540.        default-directory to be something non-absolute... */
  541.     {
  542.       filename = Fexpand_file_name (filename, current_buffer->directory);
  543.       if (!complete_filename_p (filename))
  544.         /* Give up on this path element! */
  545.         continue;
  546.     }
  547.  
  548.       /* Calculate maximum size of any filename made from
  549.      this path element/specified file name and any possible suffix.  */
  550.       want_size = strlen (suffix) + XSTRING (filename)->size + 1;
  551.       if (fn_size < want_size)
  552.     fn = (char *) alloca (fn_size = 100 + want_size);
  553.  
  554.       nsuffix = suffix;
  555.  
  556.       /* Loop over suffixes.  */
  557.       while (1)
  558.     {
  559.       char *esuffix = (char *) index (nsuffix, ':');
  560.       int lsuffix = esuffix ? esuffix - nsuffix : strlen (nsuffix);
  561.  
  562.       /* Concatenate path element/specified name with the suffix.  */
  563.       strncpy (fn, XSTRING (filename)->data, XSTRING (filename)->size);
  564.       fn[XSTRING (filename)->size] = 0;
  565.       if (lsuffix != 0)  /* Bug happens on CCI if lsuffix is 0.  */
  566.         strncat (fn, nsuffix, lsuffix);
  567.  
  568.       /* Ignore file if it's a directory.  */
  569.       if (stat (fn, &st) >= 0
  570.           && (st.st_mode & S_IFMT) != S_IFDIR)
  571.         {
  572.           /* Check that we can access or open it.  */
  573.           if (exec_only)
  574.         fd = (access (fn, X_OK) == 0) ? 1 : -1;
  575.           else
  576.         fd = open (fn, 0, 0);
  577.  
  578.           if (fd >= 0)
  579.         {
  580.           /* We succeeded; return this descriptor and filename.  */
  581.           if (storeptr)
  582.             *storeptr = build_string (fn);
  583.           RETURN_UNGCPRO (fd);
  584.         }
  585.         }
  586.  
  587.       /* Advance to next suffix.  */
  588.       if (esuffix == 0)
  589.         break;
  590.       nsuffix += lsuffix + 1;
  591.     }
  592.       if (absolute)
  593.     RETURN_UNGCPRO (-1);
  594.     }
  595.  
  596.   RETURN_UNGCPRO (-1);
  597. }
  598.  
  599.  
  600. /* Merge the list we've accumulated of globals from the current input source
  601.    into the load_history variable.  The details depend on whether
  602.    the source has an associated file name or not. */
  603.  
  604. static void
  605. build_load_history (stream, source)
  606.      FILE *stream;
  607.      Lisp_Object source;
  608. {
  609.   register Lisp_Object tail, prev, newelt;
  610.   register Lisp_Object tem, tem2;
  611.   register int foundit, loading;
  612.  
  613.   /* Don't bother recording anything for preloaded files.  */
  614.   if (!NILP (Vpurify_flag))
  615.     return;
  616.  
  617.   loading = stream || !NARROWED;
  618.  
  619.   tail = Vload_history;
  620.   prev = Qnil;
  621.   foundit = 0;
  622.   while (!NILP (tail))
  623.     {
  624.       tem = Fcar (tail);
  625.  
  626.       /* Find the feature's previous assoc list... */
  627.       if (!NILP (Fequal (source, Fcar (tem))))
  628.     {
  629.       foundit = 1;
  630.  
  631.       /*  If we're loading, remove it. */
  632.       if (loading)
  633.         {      
  634.           if (NILP (prev))
  635.         Vload_history = Fcdr (tail);
  636.           else
  637.         Fsetcdr (prev, Fcdr (tail));
  638.         }
  639.  
  640.       /*  Otherwise, cons on new symbols that are not already members.  */
  641.       else
  642.         {
  643.           tem2 = Vcurrent_load_list;
  644.  
  645.           while (CONSP (tem2))
  646.         {
  647.           newelt = Fcar (tem2);
  648.  
  649.           if (NILP (Fmemq (newelt, tem)))
  650.             Fsetcar (tail, Fcons (Fcar (tem),
  651.                       Fcons (newelt, Fcdr (tem))));
  652.  
  653.           tem2 = Fcdr (tem2);
  654.           QUIT;
  655.         }
  656.         }
  657.     }
  658.       else
  659.     prev = tail;
  660.       tail = Fcdr (tail);
  661.       QUIT;
  662.     }
  663.  
  664.   /* If we're loading, cons the new assoc onto the front of load-history,
  665.      the most-recently-loaded position.  Also do this if we didn't find
  666.      an existing member for the current source.  */
  667.   if (loading || !foundit)
  668.     Vload_history = Fcons (Fnreverse (Vcurrent_load_list),
  669.                Vload_history);
  670. }
  671.  
  672. Lisp_Object
  673. unreadpure ()    /* Used as unwind-protect function in readevalloop */
  674. {
  675.   read_pure = 0;
  676.   return Qnil;
  677. }
  678.  
  679. static void
  680. readevalloop (readcharfun, stream, sourcename, evalfun, printflag)
  681.      Lisp_Object readcharfun;
  682.      FILE *stream;
  683.      Lisp_Object sourcename;
  684.      Lisp_Object (*evalfun) ();
  685.      int printflag;
  686. {
  687.   register int c;
  688.   register Lisp_Object val;
  689.   int count = specpdl_ptr - specpdl;
  690.   struct gcpro gcpro1;
  691.   struct buffer *b = 0;
  692.  
  693.   if (BUFFERP (readcharfun))
  694.     b = XBUFFER (readcharfun);
  695.   else if (MARKERP (readcharfun))
  696.     b = XMARKER (readcharfun)->buffer;
  697.  
  698.   specbind (Qstandard_input, readcharfun);
  699.   specbind (Qcurrent_load_list, Qnil);
  700.  
  701.   GCPRO1 (sourcename);
  702.  
  703.   LOADHIST_ATTACH (sourcename);
  704.  
  705.   while (1)
  706.     {
  707.       if (b != 0 && NILP (b->name))
  708.     error ("Reading from killed buffer");
  709.  
  710.       instream = stream;
  711.       c = READCHAR;
  712.       if (c == ';')
  713.     {
  714.       while ((c = READCHAR) != '\n' && c != -1);
  715.       continue;
  716.     }
  717.       if (c < 0) break;
  718.       if (c == ' ' || c == '\t' || c == '\n' || c == '\f') continue;
  719.  
  720.       if (!NILP (Vpurify_flag) && c == '(')
  721.     {
  722.       record_unwind_protect (unreadpure, Qnil);
  723.       val = read_list (-1, readcharfun);
  724.       unbind_to (count + 1, Qnil);
  725.     }
  726.       else
  727.     {
  728.       UNREAD (c);
  729.       val = read0 (readcharfun);
  730.     }
  731.  
  732.       val = (*evalfun) (val);
  733.       if (printflag)
  734.     {
  735.       Vvalues = Fcons (val, Vvalues);
  736.       if (EQ (Vstandard_output, Qt))
  737.         Fprin1 (val, Qnil);
  738.       else
  739.         Fprint (val, Qnil);
  740.     }
  741.     }
  742.  
  743.   build_load_history (stream, sourcename);
  744.   UNGCPRO;
  745.  
  746.   unbind_to (count, Qnil);
  747. }
  748.  
  749. #ifndef standalone
  750.  
  751. DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 2, "",
  752.   "Execute the current buffer as Lisp code.\n\
  753. Programs can pass two arguments, BUFFER and PRINTFLAG.\n\
  754. BUFFER is the buffer to evaluate (nil means use current buffer).\n\
  755. PRINTFLAG controls printing of output:\n\
  756. nil means discard it; anything else is stream for print.\n\
  757. \n\
  758. If there is no error, point does not move.  If there is an error,\n\
  759. point remains at the end of the last character read from the buffer.")
  760.   (bufname, printflag)
  761.      Lisp_Object bufname, printflag;
  762. {
  763.   int count = specpdl_ptr - specpdl;
  764.   Lisp_Object tem, buf;
  765.  
  766.   if (NILP (bufname))
  767.     buf = Fcurrent_buffer ();
  768.   else
  769.     buf = Fget_buffer (bufname);
  770.   if (NILP (buf))
  771.     error ("No such buffer.");
  772.  
  773.   if (NILP (printflag))
  774.     tem = Qsymbolp;
  775.   else
  776.     tem = printflag;
  777.   specbind (Qstandard_output, tem);
  778.   record_unwind_protect (save_excursion_restore, save_excursion_save ());
  779.   BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
  780.   readevalloop (buf, 0, XBUFFER (buf)->filename, Feval, !NILP (printflag));
  781.   unbind_to (count, Qnil);
  782.  
  783.   return Qnil;
  784. }
  785.  
  786. #if 0
  787. DEFUN ("eval-current-buffer", Feval_current_buffer, Seval_current_buffer, 0, 1, "",
  788.   "Execute the current buffer as Lisp code.\n\
  789. Programs can pass argument PRINTFLAG which controls printing of output:\n\
  790. nil means discard it; anything else is stream for print.\n\
  791. \n\
  792. If there is no error, point does not move.  If there is an error,\n\
  793. point remains at the end of the last character read from the buffer.")
  794.   (printflag)
  795.      Lisp_Object printflag;
  796. {
  797.   int count = specpdl_ptr - specpdl;
  798.   Lisp_Object tem, cbuf;
  799.  
  800.   cbuf = Fcurrent_buffer ()
  801.  
  802.   if (NILP (printflag))
  803.     tem = Qsymbolp;
  804.   else
  805.     tem = printflag;
  806.   specbind (Qstandard_output, tem);
  807.   record_unwind_protect (save_excursion_restore, save_excursion_save ());
  808.   SET_PT (BEGV);
  809.   readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag));
  810.   return unbind_to (count, Qnil);
  811. }
  812. #endif
  813.  
  814. DEFUN ("eval-region", Feval_region, Seval_region, 2, 3, "r",
  815.   "Execute the region as Lisp code.\n\
  816. When called from programs, expects two arguments,\n\
  817. giving starting and ending indices in the current buffer\n\
  818. of the text to be executed.\n\
  819. Programs can pass third argument PRINTFLAG which controls output:\n\
  820. nil means discard it; anything else is stream for printing it.\n\
  821. \n\
  822. If there is no error, point does not move.  If there is an error,\n\
  823. point remains at the end of the last character read from the buffer.")
  824.   (b, e, printflag)
  825.      Lisp_Object b, e, printflag;
  826. {
  827.   int count = specpdl_ptr - specpdl;
  828.   Lisp_Object tem, cbuf;
  829.  
  830.   cbuf = Fcurrent_buffer ();
  831.  
  832.   if (NILP (printflag))
  833.     tem = Qsymbolp;
  834.   else
  835.     tem = printflag;
  836.   specbind (Qstandard_output, tem);
  837.  
  838.   if (NILP (printflag))
  839.     record_unwind_protect (save_excursion_restore, save_excursion_save ());
  840.   record_unwind_protect (save_restriction_restore, save_restriction_save ());
  841.  
  842.   /* This both uses b and checks its type.  */
  843.   Fgoto_char (b);
  844.   Fnarrow_to_region (make_number (BEGV), e);
  845.   readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag));
  846.  
  847.   return unbind_to (count, Qnil);
  848. }
  849.  
  850. #endif /* standalone */
  851.  
  852. DEFUN ("read", Fread, Sread, 0, 1, 0,
  853.   "Read one Lisp expression as text from STREAM, return as Lisp object.\n\
  854. If STREAM is nil, use the value of `standard-input' (which see).\n\
  855. STREAM or the value of `standard-input' may be:\n\
  856.  a buffer (read from point and advance it)\n\
  857.  a marker (read from where it points and advance it)\n\
  858.  a function (call it with no arguments for each character,\n\
  859.      call it with a char as argument to push a char back)\n\
  860.  a string (takes text from string, starting at the beginning)\n\
  861.  t (read text line using minibuffer and use it).")
  862.   (readcharfun)
  863.      Lisp_Object readcharfun;
  864. {
  865.   extern Lisp_Object Fread_minibuffer ();
  866.  
  867.   if (NILP (readcharfun))
  868.     readcharfun = Vstandard_input;
  869.   if (EQ (readcharfun, Qt))
  870.     readcharfun = Qread_char;
  871.  
  872. #ifndef standalone
  873.   if (EQ (readcharfun, Qread_char))
  874.     return Fread_minibuffer (build_string ("Lisp expression: "), Qnil);
  875. #endif
  876.  
  877.   if (XTYPE (readcharfun) == Lisp_String)
  878.     return Fcar (Fread_from_string (readcharfun, Qnil, Qnil));
  879.  
  880.   return read0 (readcharfun);
  881. }
  882.  
  883. DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0,
  884.   "Read one Lisp expression which is represented as text by STRING.\n\
  885. Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\
  886. START and END optionally delimit a substring of STRING from which to read;\n\
  887.  they default to 0 and (length STRING) respectively.")
  888.   (string, start, end)
  889.      Lisp_Object string, start, end;
  890. {
  891.   int startval, endval;
  892.   Lisp_Object tem;
  893.  
  894.   CHECK_STRING (string,0);
  895.  
  896.   if (NILP (end))
  897.     endval = XSTRING (string)->size;
  898.   else
  899.     { CHECK_NUMBER (end,2);
  900.       endval = XINT (end);
  901.       if (endval < 0 || endval > XSTRING (string)->size)
  902.     args_out_of_range (string, end);
  903.     }
  904.  
  905.   if (NILP (start))
  906.     startval = 0;
  907.   else
  908.     { CHECK_NUMBER (start,1);
  909.       startval = XINT (start);
  910.       if (startval < 0 || startval > endval)
  911.     args_out_of_range (string, start);
  912.     }
  913.  
  914.   read_from_string_index = startval;
  915.   read_from_string_limit = endval;
  916.  
  917.   tem = read0 (string);
  918.   return Fcons (tem, make_number (read_from_string_index));
  919. }
  920.  
  921. /* Use this for recursive reads, in contexts where internal tokens are not allowed. */
  922.  
  923. static Lisp_Object
  924. read0 (readcharfun)
  925.      Lisp_Object readcharfun;
  926. {
  927.   register Lisp_Object val;
  928.   char c;
  929.  
  930.   val = read1 (readcharfun);
  931.   if (XTYPE (val) == Lisp_Internal)
  932.     {
  933.       c = XINT (val);
  934.       return Fsignal (Qinvalid_read_syntax, Fcons (make_string (&c, 1), Qnil));
  935.     }
  936.  
  937.   return val;
  938. }
  939.  
  940. static int read_buffer_size;
  941. char *read_buffer; /* CHFIXME */
  942.  
  943. static int
  944. read_escape (readcharfun)
  945.      Lisp_Object readcharfun;
  946. {
  947.   register int c = READCHAR;
  948.   switch (c)
  949.     {
  950.     case 'a':
  951.       return '\007';
  952.     case 'b':
  953.       return '\b';
  954.     case 'd':
  955.       return 0177;
  956.     case 'e':
  957.       return 033;
  958.     case 'f':
  959.       return '\f';
  960.     case 'n':
  961.       return '\n';
  962.     case 'r':
  963.       return '\r';
  964.     case 't':
  965.       return '\t';
  966.     case 'v':
  967.       return '\v';
  968.     case '\n':
  969.       return -1;
  970.  
  971.     case 'M':
  972.       c = READCHAR;
  973.       if (c != '-')
  974.     error ("Invalid escape character syntax");
  975.       c = READCHAR;
  976.       if (c == '\\')
  977.     c = read_escape (readcharfun);
  978.       return c | meta_modifier;
  979.  
  980.     case 'S':
  981.       c = READCHAR;
  982.       if (c != '-')
  983.     error ("Invalid escape character syntax");
  984.       c = READCHAR;
  985.       if (c == '\\')
  986.     c = read_escape (readcharfun);
  987.       return c | shift_modifier;
  988.  
  989.     case 'H':
  990.       c = READCHAR;
  991.       if (c != '-')
  992.     error ("Invalid escape character syntax");
  993.       c = READCHAR;
  994.       if (c == '\\')
  995.     c = read_escape (readcharfun);
  996.       return c | hyper_modifier;
  997.  
  998.     case 'A':
  999.       c = READCHAR;
  1000.       if (c != '-')
  1001.     error ("Invalid escape character syntax");
  1002.       c = READCHAR;
  1003.       if (c == '\\')
  1004.     c = read_escape (readcharfun);
  1005.       return c | alt_modifier;
  1006.  
  1007.     case 's':
  1008.       c = READCHAR;
  1009.       if (c != '-')
  1010.     error ("Invalid escape character syntax");
  1011.       c = READCHAR;
  1012.       if (c == '\\')
  1013.     c = read_escape (readcharfun);
  1014.       return c | super_modifier;
  1015.  
  1016.     case 'C':
  1017.       c = READCHAR;
  1018.       if (c != '-')
  1019.     error ("Invalid escape character syntax");
  1020.     case '^':
  1021.       c = READCHAR;
  1022.       if (c == '\\')
  1023.     c = read_escape (readcharfun);
  1024.       if ((c & 0177) == '?')
  1025.     return 0177 | c;
  1026.       /* ASCII control chars are made from letters (both cases),
  1027.      as well as the non-letters within 0100...0137.  */
  1028.       else if ((c & 0137) >= 0101 && (c & 0137) <= 0132)
  1029.     return (c & (037 | ~0177));
  1030.       else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
  1031.     return (c & (037 | ~0177));
  1032.       else
  1033.     return c | ctrl_modifier;
  1034.  
  1035.     case '0':
  1036.     case '1':
  1037.     case '2':
  1038.     case '3':
  1039.     case '4':
  1040.     case '5':
  1041.     case '6':
  1042.     case '7':
  1043.       /* An octal escape, as in ANSI C.  */
  1044.       {
  1045.     register int i = c - '0';
  1046.     register int count = 0;
  1047.     while (++count < 3)
  1048.       {
  1049.         if ((c = READCHAR) >= '0' && c <= '7')
  1050.           {
  1051.         i *= 8;
  1052.         i += c - '0';
  1053.           }
  1054.         else
  1055.           {
  1056.         UNREAD (c);
  1057.         break;
  1058.           }
  1059.       }
  1060.     return i;
  1061.       }
  1062.  
  1063.     case 'x':
  1064.       /* A hex escape, as in ANSI C.  */
  1065.       {
  1066.     int i = 0;
  1067.     while (1)
  1068.       {
  1069.         c = READCHAR;
  1070.         if (c >= '0' && c <= '9')
  1071.           {
  1072.         i *= 16;
  1073.         i += c - '0';
  1074.           }
  1075.         else if ((c >= 'a' && c <= 'f')
  1076.              || (c >= 'A' && c <= 'F'))
  1077.           {
  1078.         i *= 16;
  1079.         if (c >= 'a' && c <= 'f')
  1080.           i += c - 'a' + 10;
  1081.         else
  1082.           i += c - 'A' + 10;
  1083.           }
  1084.         else
  1085.           {
  1086.         UNREAD (c);
  1087.         break;
  1088.           }
  1089.       }
  1090.     return i;
  1091.       }
  1092.  
  1093.     default:
  1094.       return c;
  1095.     }
  1096. }
  1097.  
  1098. static Lisp_Object
  1099. read1 (readcharfun)
  1100.      register Lisp_Object readcharfun;
  1101. {
  1102.   register int c;
  1103.  
  1104.  retry:
  1105.  
  1106.   c = READCHAR;
  1107.   if (c < 0) return Fsignal (Qend_of_file, Qnil);
  1108.  
  1109.   switch (c)
  1110.     {
  1111.     case '(':
  1112.       return read_list (0, readcharfun);
  1113.  
  1114.     case '[':
  1115.       return read_vector (readcharfun);
  1116.  
  1117.     case ')':
  1118.     case ']':
  1119.       {
  1120.     register Lisp_Object val;
  1121.     XSET (val, Lisp_Internal, c);
  1122.     return val;
  1123.       }
  1124.  
  1125.     case '#':
  1126.       c = READCHAR;
  1127.       if (c == '[')
  1128.     {
  1129.       /* Accept compiled functions at read-time so that we don't have to
  1130.          build them using function calls.  */
  1131.       Lisp_Object tmp;
  1132.       tmp = read_vector (readcharfun);
  1133.       return Fmake_byte_code (XVECTOR (tmp)->size,
  1134.                   XVECTOR (tmp)->contents);
  1135.     }
  1136. #ifdef USE_TEXT_PROPERTIES
  1137.       if (c == '(')
  1138.     {
  1139.       Lisp_Object tmp;
  1140.       struct gcpro gcpro1;
  1141.  
  1142.       /* Read the string itself.  */
  1143.       tmp = read1 (readcharfun);
  1144.       if (XTYPE (tmp) != Lisp_String)
  1145.         Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
  1146.       GCPRO1 (tmp);
  1147.       /* Read the intervals and their properties.  */
  1148.       while (1)
  1149.         {
  1150.           Lisp_Object beg, end, plist;
  1151.  
  1152.           beg = read1 (readcharfun);
  1153.           if (XTYPE (beg) == Lisp_Internal)
  1154.         {
  1155.           if (XINT (beg) == ')')
  1156.             break;
  1157.           Fsignal (Qinvalid_read_syntax, Fcons (make_string ("invalid string property list", 28), Qnil));
  1158.         }
  1159.           end = read1 (readcharfun);
  1160.           if (XTYPE (end) == Lisp_Internal)
  1161.         Fsignal (Qinvalid_read_syntax,
  1162.              Fcons (make_string ("invalid string property list", 28), Qnil));
  1163.         
  1164.           plist = read1 (readcharfun);
  1165.           if (XTYPE (plist) == Lisp_Internal)
  1166.         Fsignal (Qinvalid_read_syntax,
  1167.              Fcons (make_string ("invalid string property list", 28), Qnil));
  1168.           Fset_text_properties (beg, end, plist, tmp);
  1169.         }
  1170.       UNGCPRO;
  1171.       return tmp;
  1172.     }
  1173. #endif
  1174.       UNREAD (c);
  1175.       Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
  1176.  
  1177.     case ';':
  1178.       while ((c = READCHAR) >= 0 && c != '\n');
  1179.       goto retry;
  1180.  
  1181.     case '\'':
  1182.       {
  1183.     return Fcons (Qquote, Fcons (read0 (readcharfun), Qnil));
  1184.       }
  1185.  
  1186.     case '?':
  1187.       {
  1188.     register Lisp_Object val;
  1189.  
  1190.     c = READCHAR;
  1191.     if (c < 0) return Fsignal (Qend_of_file, Qnil);
  1192.  
  1193.     if (c == '\\')
  1194.       XSET (val, Lisp_Int, read_escape (readcharfun));
  1195.     else
  1196.       XSET (val, Lisp_Int, c);
  1197.  
  1198.     return val;
  1199.       }
  1200.  
  1201.     case '\"':
  1202.       {
  1203.     register char *p = read_buffer;
  1204.     register char *end = read_buffer + read_buffer_size;
  1205.     register int c;
  1206.     int cancel = 0;
  1207.  
  1208.     while ((c = READCHAR) >= 0
  1209.            && c != '\"')
  1210.       {
  1211.         if (p == end)
  1212.           {
  1213.         char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  1214.         p += new - read_buffer;
  1215.         read_buffer += new - read_buffer;
  1216.         end = read_buffer + read_buffer_size;
  1217.           }
  1218.         if (c == '\\')
  1219.           c = read_escape (readcharfun);
  1220.         /* c is -1 if \ newline has just been seen */
  1221.         if (c == -1)
  1222.           {
  1223.         if (p == read_buffer)
  1224.           cancel = 1;
  1225.           }
  1226.         else
  1227.           {
  1228.         /* Allow `\C- ' and `\C-?'.  */
  1229.         if (c == (CHAR_CTL | ' '))
  1230.           c = 0;
  1231.         else if (c == (CHAR_CTL | '?'))
  1232.           c = 127;
  1233.  
  1234.         if (c & CHAR_META)
  1235.           /* Move the meta bit to the right place for a string.  */
  1236.           c = (c & ~CHAR_META) | 0x80;
  1237.         if (c & ~0xff)
  1238.           error ("Invalid modifier in string");
  1239.         *p++ = c;
  1240.           }
  1241.       }
  1242.     if (c < 0) return Fsignal (Qend_of_file, Qnil);
  1243.  
  1244.     /* If purifying, and string starts with \ newline,
  1245.        return zero instead.  This is for doc strings
  1246.        that we are really going to find in etc/DOC.nn.nn  */
  1247.     if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel)
  1248.       return make_number (0);
  1249.  
  1250.     if (read_pure)
  1251.       return make_pure_string (read_buffer, p - read_buffer);
  1252.     else
  1253.       return make_string (read_buffer, p - read_buffer);
  1254.       }
  1255.  
  1256.     case '.':
  1257.       {
  1258. #ifdef LISP_FLOAT_TYPE
  1259.     /* If a period is followed by a number, then we should read it
  1260.        as a floating point number.  Otherwise, it denotes a dotted
  1261.        pair.  */
  1262.     int next_char = READCHAR;
  1263.     UNREAD (next_char);
  1264.  
  1265.     if (! isdigit (next_char))
  1266. #endif
  1267.       {
  1268.         register Lisp_Object val;
  1269.         XSET (val, Lisp_Internal, c);
  1270.         return val;
  1271.       }
  1272.  
  1273.     /* Otherwise, we fall through!  Note that the atom-reading loop
  1274.        below will now loop at least once, assuring that we will not
  1275.        try to UNREAD two characters in a row.  */
  1276.       }
  1277.     default:
  1278.       if (c <= 040) goto retry;
  1279.       {
  1280.     register char *p = read_buffer;
  1281.     int quoted = 0;
  1282.  
  1283.     {
  1284.       register char *end = read_buffer + read_buffer_size;
  1285.  
  1286.       while (c > 040 && 
  1287.          !(c == '\"' || c == '\'' || c == ';' || c == '?'
  1288.            || c == '(' || c == ')'
  1289. #ifndef LISP_FLOAT_TYPE
  1290.            /* If we have floating-point support, then we need
  1291.               to allow <digits><dot><digits>.  */
  1292.            || c =='.'
  1293. #endif /* not LISP_FLOAT_TYPE */
  1294.            || c == '[' || c == ']' || c == '#'
  1295.            ))
  1296.         {
  1297.           if (p == end)
  1298.         {
  1299.           register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  1300.           p += new - read_buffer;
  1301.           read_buffer += new - read_buffer;
  1302.           end = read_buffer + read_buffer_size;
  1303.         }
  1304.           if (c == '\\')
  1305.         {
  1306.           c = READCHAR;
  1307.           quoted = 1;
  1308.         }
  1309.           *p++ = c;
  1310.           c = READCHAR;
  1311.         }
  1312.  
  1313.       if (p == end)
  1314.         {
  1315.           char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  1316.           p += new - read_buffer;
  1317.           read_buffer += new - read_buffer;
  1318. /*          end = read_buffer + read_buffer_size;  */
  1319.         }
  1320.       *p = 0;
  1321.       if (c >= 0)
  1322.         UNREAD (c);
  1323.     }
  1324.  
  1325.     if (!quoted)
  1326.       {
  1327.         register char *p1;
  1328.         register Lisp_Object val;
  1329.         p1 = read_buffer;
  1330.         if (*p1 == '+' || *p1 == '-') p1++;
  1331.         /* Is it an integer? */
  1332.         if (p1 != p)
  1333.           {
  1334.         while (p1 != p && (c = *p1) >= '0' && c <= '9') p1++;
  1335. #ifdef LISP_FLOAT_TYPE
  1336.         /* Integers can have trailing decimal points.  */
  1337.         if (p1 > read_buffer && p1 < p && *p1 == '.') p1++;
  1338. #endif
  1339.         if (p1 == p)
  1340.           /* It is an integer. */
  1341.           {
  1342. #ifdef LISP_FLOAT_TYPE
  1343.             if (p1[-1] == '.')
  1344.               p1[-1] = '\0';
  1345. #endif
  1346.             XSET (val, Lisp_Int, atoi (read_buffer));
  1347.             return val;
  1348.           }
  1349.           }
  1350. #ifdef LISP_FLOAT_TYPE
  1351.         if (isfloat_string (read_buffer))
  1352.           return make_float (atof (read_buffer));
  1353. #endif
  1354.       }
  1355.  
  1356.     return intern (read_buffer);
  1357.       }
  1358.     }
  1359. }
  1360.  
  1361. #ifdef LISP_FLOAT_TYPE
  1362.  
  1363. #define LEAD_INT 1
  1364. #define DOT_CHAR 2
  1365. #define TRAIL_INT 4
  1366. #define E_CHAR 8
  1367. #define EXP_INT 16
  1368.  
  1369. int
  1370. isfloat_string (cp)
  1371.      register char *cp;
  1372. {
  1373.   register state;
  1374.   
  1375.   state = 0;
  1376.   if (*cp == '+' || *cp == '-')
  1377.     cp++;
  1378.  
  1379.   if (isdigit(*cp))
  1380.     {
  1381.       state |= LEAD_INT;
  1382.       while (isdigit (*cp))
  1383.     cp ++;
  1384.     }
  1385.   if (*cp == '.')
  1386.     {
  1387.       state |= DOT_CHAR;
  1388.       cp++;
  1389.     }
  1390.   if (isdigit(*cp))
  1391.     {
  1392.       state |= TRAIL_INT;
  1393.       while (isdigit (*cp))
  1394.     cp++;
  1395.     }
  1396.   if (*cp == 'e')
  1397.     {
  1398.       state |= E_CHAR;
  1399.       cp++;
  1400.     }
  1401.   if ((*cp == '+') || (*cp == '-'))
  1402.     cp++;
  1403.  
  1404.   if (isdigit (*cp))
  1405.     {
  1406.       state |= EXP_INT;
  1407.       while (isdigit (*cp))
  1408.     cp++;
  1409.     }
  1410.   return (*cp == 0
  1411.       && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT)
  1412.           || state == (DOT_CHAR|TRAIL_INT)
  1413.           || state == (LEAD_INT|E_CHAR|EXP_INT)
  1414.           || state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)
  1415.           || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)));
  1416. }
  1417. #endif /* LISP_FLOAT_TYPE */
  1418.  
  1419. static Lisp_Object
  1420. read_vector (readcharfun)
  1421.      Lisp_Object readcharfun;
  1422. {
  1423.   register int i;
  1424.   register int size;
  1425.   register Lisp_Object *ptr;
  1426.   register Lisp_Object tem, vector;
  1427.   register struct Lisp_Cons *otem;
  1428.   Lisp_Object len;
  1429.  
  1430.   tem = read_list (1, readcharfun);
  1431.   len = Flength (tem);
  1432.   vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil));
  1433.  
  1434.  
  1435.   size = XVECTOR (vector)->size;
  1436.   ptr = XVECTOR (vector)->contents;
  1437.   for (i = 0; i < size; i++)
  1438.     {
  1439.       ptr[i] = read_pure ? Fpurecopy (Fcar (tem)) : Fcar (tem);
  1440.       otem = XCONS (tem);
  1441.       tem = Fcdr (tem);
  1442.       free_cons (otem);
  1443.     }
  1444.   return vector;
  1445. }
  1446.   
  1447. /* flag = 1 means check for ] to terminate rather than ) and .
  1448.    flag = -1 means check for starting with defun
  1449.     and make structure pure.  */
  1450.  
  1451. static Lisp_Object
  1452. read_list (flag, readcharfun)
  1453.      int flag;
  1454.      register Lisp_Object readcharfun;
  1455. {
  1456.   /* -1 means check next element for defun,
  1457.      0 means don't check,
  1458.      1 means already checked and found defun. */
  1459.   int defunflag = flag < 0 ? -1 : 0;
  1460.   Lisp_Object val, tail;
  1461.   register Lisp_Object elt, tem;
  1462.   struct gcpro gcpro1, gcpro2;
  1463.  
  1464.   val = Qnil;
  1465.   tail = Qnil;
  1466.  
  1467.   while (1)
  1468.     {
  1469.       GCPRO2 (val, tail);
  1470.       elt = read1 (readcharfun);
  1471.       UNGCPRO;
  1472.       if (XTYPE (elt) == Lisp_Internal)
  1473.     {
  1474.       if (flag > 0)
  1475.         {
  1476.           if (XINT (elt) == ']')
  1477.         return val;
  1478.           return Fsignal (Qinvalid_read_syntax, Fcons (make_string (") or . in a vector", 18), Qnil));
  1479.         }
  1480.       if (XINT (elt) == ')')
  1481.         return val;
  1482.       if (XINT (elt) == '.')
  1483.         {
  1484.           GCPRO2 (val, tail);
  1485.           if (!NILP (tail))
  1486.         XCONS (tail)->cdr = read0 (readcharfun);
  1487.           else
  1488.         val = read0 (readcharfun);
  1489.           elt = read1 (readcharfun);
  1490.           UNGCPRO;
  1491.           if (XTYPE (elt) == Lisp_Internal && XINT (elt) == ')')
  1492.         return val;
  1493.           return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil));
  1494.         }
  1495.       return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil));
  1496.     }
  1497.       tem = (read_pure && flag <= 0
  1498.          ? pure_cons (elt, Qnil)
  1499.          : Fcons (elt, Qnil));
  1500.       if (!NILP (tail))
  1501.     XCONS (tail)->cdr = tem;
  1502.       else
  1503.     val = tem;
  1504.       tail = tem;
  1505.       if (defunflag < 0)
  1506.     defunflag = EQ (elt, Qdefun);
  1507.       else if (defunflag > 0)
  1508.     read_pure = 1;
  1509.     }
  1510. }
  1511.  
  1512. Lisp_Object Vobarray;
  1513. Lisp_Object initial_obarray;
  1514.  
  1515. Lisp_Object
  1516. check_obarray (obarray)
  1517.      Lisp_Object obarray;
  1518. {
  1519.   while (XTYPE (obarray) != Lisp_Vector || XVECTOR (obarray)->size == 0)
  1520.     {
  1521.       /* If Vobarray is now invalid, force it to be valid.  */
  1522.       if (EQ (Vobarray, obarray)) Vobarray = initial_obarray;
  1523.  
  1524.       obarray = wrong_type_argument (Qvectorp, obarray);
  1525.     }
  1526.   return obarray;
  1527. }
  1528.  
  1529. static int hash_string ();
  1530. Lisp_Object oblookup ();
  1531.  
  1532. Lisp_Object
  1533. intern (str)
  1534.      char *str;
  1535. {
  1536.   Lisp_Object tem;
  1537.   int len = strlen (str);
  1538.   Lisp_Object obarray;
  1539.  
  1540.   obarray = Vobarray;
  1541.   if (XTYPE (obarray) != Lisp_Vector || XVECTOR (obarray)->size == 0)
  1542.     obarray = check_obarray (obarray);
  1543.   tem = oblookup (obarray, str, len);
  1544.   if (XTYPE (tem) == Lisp_Symbol)
  1545.     return tem;
  1546.   return Fintern ((!NILP (Vpurify_flag)
  1547.            ? make_pure_string (str, len)
  1548.            : make_string (str, len)),
  1549.           obarray);
  1550. }
  1551.  
  1552. DEFUN ("intern", Fintern, Sintern, 1, 2, 0,
  1553.   "Return the canonical symbol whose name is STRING.\n\
  1554. If there is none, one is created by this function and returned.\n\
  1555. A second optional argument specifies the obarray to use;\n\
  1556. it defaults to the value of `obarray'.")
  1557.   (str, obarray)
  1558.      Lisp_Object str, obarray;
  1559. {
  1560.   register Lisp_Object tem, sym, *ptr;
  1561.  
  1562.   if (NILP (obarray)) obarray = Vobarray;
  1563.   obarray = check_obarray (obarray);
  1564.  
  1565.   CHECK_STRING (str, 0);
  1566.  
  1567.   tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size);
  1568.   if (XTYPE (tem) != Lisp_Int)
  1569.     return tem;
  1570.  
  1571.   if (!NILP (Vpurify_flag))
  1572.     str = Fpurecopy (str);
  1573.   sym = Fmake_symbol (str);
  1574.  
  1575.   ptr = &XVECTOR (obarray)->contents[XINT (tem)];
  1576.   if (XTYPE (*ptr) == Lisp_Symbol)
  1577.     XSYMBOL (sym)->next = XSYMBOL (*ptr);
  1578.   else
  1579.     XSYMBOL (sym)->next = 0;
  1580.   *ptr = sym;
  1581.   return sym;
  1582. }
  1583.  
  1584. DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0,
  1585.   "Return the canonical symbol whose name is STRING, or nil if none exists.\n\
  1586. A second optional argument specifies the obarray to use;\n\
  1587. it defaults to the value of `obarray'.")
  1588.   (str, obarray)
  1589.      Lisp_Object str, obarray;
  1590. {
  1591.   register Lisp_Object tem;
  1592.  
  1593.   if (NILP (obarray)) obarray = Vobarray;
  1594.   obarray = check_obarray (obarray);
  1595.  
  1596.   CHECK_STRING (str, 0);
  1597.  
  1598.   tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size);
  1599.   if (XTYPE (tem) != Lisp_Int)
  1600.     return tem;
  1601.   return Qnil;
  1602. }
  1603.  
  1604. Lisp_Object
  1605. oblookup (obarray, ptr, size)
  1606.      Lisp_Object obarray;
  1607.      register char *ptr;
  1608.      register int size;
  1609. {
  1610.   int hash, obsize;
  1611.   register Lisp_Object tail;
  1612.   Lisp_Object bucket, tem;
  1613.  
  1614.   if (XTYPE (obarray) != Lisp_Vector
  1615.       || (obsize = XVECTOR (obarray)->size) == 0)
  1616.     {
  1617.       obarray = check_obarray (obarray);
  1618.       obsize = XVECTOR (obarray)->size;
  1619.     }
  1620.   /* Combining next two lines breaks VMS C 2.3.  */
  1621.   hash = hash_string (ptr, size);
  1622.   hash %= obsize;
  1623.   bucket = XVECTOR (obarray)->contents[hash];
  1624.   if (XFASTINT (bucket) == 0)
  1625.     ;
  1626.   else if (XTYPE (bucket) != Lisp_Symbol)
  1627.     error ("Bad data in guts of obarray"); /* Like CADR error message */
  1628.   else for (tail = bucket; ; XSET (tail, Lisp_Symbol, XSYMBOL (tail)->next))
  1629.       {
  1630.     if (XSYMBOL (tail)->name->size == size &&
  1631.         !bcmp (XSYMBOL (tail)->name->data, ptr, size))
  1632.       return tail;
  1633.     else if (XSYMBOL (tail)->next == 0)
  1634.       break;
  1635.       }
  1636.   XSET (tem, Lisp_Int, hash);
  1637.   return tem;
  1638. }
  1639.  
  1640. static int
  1641. hash_string (ptr, len)
  1642.      unsigned char *ptr;
  1643.      int len;
  1644. {
  1645.   register unsigned char *p = ptr;
  1646.   register unsigned char *end = p + len;
  1647.   register unsigned char c;
  1648.   register int hash = 0;
  1649.  
  1650.   while (p != end)
  1651.     {
  1652.       c = *p++;
  1653.       if (c >= 0140) c -= 40;
  1654.       hash = ((hash<<3) + (hash>>28) + c);
  1655.     }
  1656.   return hash & 07777777777;
  1657. }
  1658.  
  1659. void
  1660. map_obarray (obarray, fn, arg)
  1661.      Lisp_Object obarray;
  1662.      int (*fn) ();
  1663.      Lisp_Object arg;
  1664. {
  1665.   register int i;
  1666.   register Lisp_Object tail;
  1667.   CHECK_VECTOR (obarray, 1);
  1668.   for (i = XVECTOR (obarray)->size - 1; i >= 0; i--)
  1669.     {
  1670.       tail = XVECTOR (obarray)->contents[i];
  1671.       if (XFASTINT (tail) != 0)
  1672.     while (1)
  1673.       {
  1674.         (*fn) (tail, arg);
  1675.         if (XSYMBOL (tail)->next == 0)
  1676.           break;
  1677.         XSET (tail, Lisp_Symbol, XSYMBOL (tail)->next);
  1678.       }
  1679.     }
  1680. }
  1681.  
  1682. mapatoms_1 (sym, function)
  1683.      Lisp_Object sym, function;
  1684. {
  1685.   call1 (function, sym);
  1686. }
  1687.  
  1688. DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0,
  1689.   "Call FUNCTION on every symbol in OBARRAY.\n\
  1690. OBARRAY defaults to the value of `obarray'.")
  1691.   (function, obarray)
  1692.      Lisp_Object function, obarray;
  1693. {
  1694.   Lisp_Object tem;
  1695.  
  1696.   if (NILP (obarray)) obarray = Vobarray;
  1697.   obarray = check_obarray (obarray);
  1698.  
  1699.   map_obarray (obarray, mapatoms_1, function);
  1700.   return Qnil;
  1701. }
  1702.  
  1703. #define OBARRAY_SIZE 1511
  1704.  
  1705. void
  1706. init_obarray ()
  1707. {
  1708.   Lisp_Object oblength;
  1709.   int hash;
  1710.   Lisp_Object *tem;
  1711.  
  1712.   XFASTINT (oblength) = OBARRAY_SIZE;
  1713.  
  1714.   Qnil = Fmake_symbol (make_pure_string ("nil", 3));
  1715.   Vobarray = Fmake_vector (oblength, make_number (0));
  1716.   initial_obarray = Vobarray;
  1717.   staticpro (&initial_obarray);
  1718.   /* Intern nil in the obarray */
  1719.   /* These locals are to kludge around a pyramid compiler bug. */
  1720.   hash = hash_string ("nil", 3);
  1721.   /* Separate statement here to avoid VAXC bug. */
  1722.   hash %= OBARRAY_SIZE;
  1723.   tem = &XVECTOR (Vobarray)->contents[hash];
  1724.   *tem = Qnil;
  1725.  
  1726.   Qunbound = Fmake_symbol (make_pure_string ("unbound", 7));
  1727.   XSYMBOL (Qnil)->function = Qunbound;
  1728.   XSYMBOL (Qunbound)->value = Qunbound;
  1729.   XSYMBOL (Qunbound)->function = Qunbound;
  1730.  
  1731.   Qt = intern ("t");
  1732.   XSYMBOL (Qnil)->value = Qnil;
  1733.   XSYMBOL (Qnil)->plist = Qnil;
  1734.   XSYMBOL (Qt)->value = Qt;
  1735.  
  1736.   /* Qt is correct even if CANNOT_DUMP.  loadup.el will set to nil at end.  */
  1737.   Vpurify_flag = Qt;
  1738.  
  1739.   Qvariable_documentation = intern ("variable-documentation");
  1740.  
  1741.   read_buffer_size = 100;
  1742.   read_buffer = (char *) malloc (read_buffer_size);
  1743. }
  1744.  
  1745. void
  1746. defsubr (sname)
  1747.      struct Lisp_Subr *sname;
  1748. {
  1749.   Lisp_Object sym;
  1750.   sym = intern (sname->symbol_name);
  1751.   XSET (XSYMBOL (sym)->function, Lisp_Subr, sname);
  1752. }
  1753.  
  1754. #ifdef NOTDEF /* use fset in subr.el now */
  1755. void
  1756. defalias (sname, string)
  1757.      struct Lisp_Subr *sname;
  1758.      char *string;
  1759. {
  1760.   Lisp_Object sym;
  1761.   sym = intern (string);
  1762.   XSET (XSYMBOL (sym)->function, Lisp_Subr, sname);
  1763. }
  1764. #endif /* NOTDEF */
  1765.  
  1766. /* Define an "integer variable"; a symbol whose value is forwarded
  1767.  to a C variable of type int.  Sample call: */
  1768.   /* DEFVARINT ("indent-tabs-mode", &indent_tabs_mode, "Documentation");  */
  1769.  
  1770. void
  1771. defvar_int (namestring, address)
  1772.      char *namestring;
  1773.      int *address;
  1774. {
  1775.   Lisp_Object sym;
  1776.   sym = intern (namestring);
  1777.   XSET (XSYMBOL (sym)->value, Lisp_Intfwd, address);
  1778. }
  1779.  
  1780. /* Similar but define a variable whose value is T if address contains 1,
  1781.  NIL if address contains 0 */
  1782.  
  1783. void
  1784. defvar_bool (namestring, address)
  1785.      char *namestring;
  1786.      int *address;
  1787. {
  1788.   Lisp_Object sym;
  1789.   sym = intern (namestring);
  1790.   XSET (XSYMBOL (sym)->value, Lisp_Boolfwd, address);
  1791. }
  1792.  
  1793. /* Similar but define a variable whose value is the Lisp Object stored at address. */
  1794.  
  1795. void
  1796. defvar_lisp (namestring, address)
  1797.      char *namestring;
  1798.      Lisp_Object *address;
  1799. {
  1800.   Lisp_Object sym;
  1801.   sym = intern (namestring);
  1802.   XSET (XSYMBOL (sym)->value, Lisp_Objfwd, address);
  1803.   staticpro (address);
  1804. }
  1805.  
  1806. /* Similar but don't request gc-marking of the C variable.
  1807.    Used when that variable will be gc-marked for some other reason,
  1808.    since marking the same slot twice can cause trouble with strings.  */
  1809.  
  1810. void
  1811. defvar_lisp_nopro (namestring, address)
  1812.      char *namestring;
  1813.      Lisp_Object *address;
  1814. {
  1815.   Lisp_Object sym;
  1816.   sym = intern (namestring);
  1817.   XSET (XSYMBOL (sym)->value, Lisp_Objfwd, address);
  1818. }
  1819.  
  1820. #ifndef standalone
  1821.  
  1822. /* Similar but define a variable whose value is the Lisp Object stored in
  1823.  the current buffer.  address is the address of the slot in the buffer that is current now. */
  1824.  
  1825. void
  1826. defvar_per_buffer (namestring, address, type, doc)
  1827.      char *namestring;
  1828.      Lisp_Object *address;
  1829.      Lisp_Object type;
  1830.      char *doc;
  1831. {
  1832.   Lisp_Object sym;
  1833.   int offset;
  1834.   extern struct buffer buffer_local_symbols;
  1835.  
  1836.   sym = intern (namestring);
  1837.   offset = (char *)address - (char *)current_buffer;
  1838.  
  1839.   XSET (XSYMBOL (sym)->value, Lisp_Buffer_Objfwd,
  1840.     (Lisp_Object *) offset);
  1841.   *(Lisp_Object *)(offset + (char *)&buffer_local_symbols) = sym;
  1842.   *(Lisp_Object *)(offset + (char *)&buffer_local_types) = type;
  1843.   if (*(int *)(offset + (char *)&buffer_local_flags) == 0)
  1844.     /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
  1845.        slot of buffer_local_flags */
  1846.     abort ();
  1847. }
  1848.  
  1849. #endif /* standalone */
  1850.  
  1851. init_lread ()
  1852. {
  1853.   char *normal;
  1854.  
  1855.   /* Compute the default load-path.  */
  1856. #ifdef CANNOT_DUMP
  1857.   normal = PATH_LOADSEARCH;
  1858.   Vload_path = decode_env_path (0, normal);
  1859. #else
  1860.   if (NILP (Vpurify_flag))
  1861.     normal = PATH_LOADSEARCH;
  1862.   else
  1863.     normal = PATH_DUMPLOADSEARCH;
  1864.  
  1865.   /* In a dumped Emacs, we normally have to reset the value of
  1866.      Vload_path from PATH_LOADSEARCH, since the value that was dumped
  1867.      uses ../lisp, instead of the path of the installed elisp
  1868.      libraries.  However, if it appears that Vload_path was changed
  1869.      from the default before dumping, don't override that value.  */
  1870.   if (initialized)
  1871.     {
  1872.       Lisp_Object dump_path;
  1873.  
  1874.       dump_path = decode_env_path (0, PATH_DUMPLOADSEARCH);
  1875.       if (! NILP (Fequal (dump_path, Vload_path)))
  1876.     {
  1877.       Vload_path = decode_env_path (0, normal);
  1878.       if (!NILP (Vinstallation_directory))
  1879.         {
  1880.           /* Add to the path the lisp subdir of the
  1881.          installation dir, if it exists.  */
  1882.           Lisp_Object tem, tem1;
  1883.           tem = Fexpand_file_name (build_string ("lisp"),
  1884.                        Vinstallation_directory);
  1885.           tem1 = Ffile_exists_p (tem);
  1886.           if (!NILP (tem1))
  1887.         {
  1888.           if (NILP (Fmember (tem, Vload_path)))
  1889.             Vload_path = nconc2 (Vload_path, Fcons (tem, Qnil));
  1890.         }
  1891.           else
  1892.         /* That dir doesn't exist, so add the build-time
  1893.            Lisp dirs instead.  */
  1894.         Vload_path = nconc2 (Vload_path, dump_path);
  1895.         }
  1896.     }
  1897.     }
  1898.   else
  1899.     Vload_path = decode_env_path (0, normal);
  1900. #endif
  1901.  
  1902.   /* Warn if dirs in the *standard* path don't exist.  */
  1903.   {
  1904.     Lisp_Object path_tail;
  1905.  
  1906.     for (path_tail = Vload_path;
  1907.      !NILP (path_tail);
  1908.      path_tail = XCONS (path_tail)->cdr)
  1909.       {
  1910.     Lisp_Object dirfile;
  1911.     dirfile = Fcar (path_tail);
  1912.     if (XTYPE (dirfile) == Lisp_String)
  1913.       {
  1914.         dirfile = Fdirectory_file_name (dirfile);
  1915.         if (access (XSTRING (dirfile)->data, 0) < 0)
  1916.           fprintf (stderr,
  1917.                "Warning: Lisp directory `%s' does not exist.\n",
  1918.                XSTRING (Fcar (path_tail))->data);
  1919.       }
  1920.       }
  1921.   }
  1922.  
  1923.   /* If the EMACSLOADPATH environment variable is set, use its value.
  1924.      This doesn't apply if we're dumping.  */
  1925.   if (NILP (Vpurify_flag)
  1926.       && egetenv ("EMACSLOADPATH"))
  1927.     Vload_path = decode_env_path ("EMACSLOADPATH", normal);
  1928.  
  1929.   Vvalues = Qnil;
  1930.  
  1931.   load_in_progress = 0;
  1932.  
  1933.   load_descriptor_list = Qnil;
  1934. }
  1935.  
  1936. void
  1937. syms_of_lread ()
  1938. {
  1939.   defsubr (&Sread);
  1940.   defsubr (&Sread_from_string);
  1941.   defsubr (&Sintern);
  1942.   defsubr (&Sintern_soft);
  1943.   defsubr (&Sload);
  1944.   defsubr (&Seval_buffer);
  1945.   defsubr (&Seval_region);
  1946.   defsubr (&Sread_char);
  1947.   defsubr (&Sread_char_exclusive);
  1948.   defsubr (&Sread_event);
  1949.   defsubr (&Sget_file_char);
  1950.   defsubr (&Smapatoms);
  1951.  
  1952.   DEFVAR_LISP ("obarray", &Vobarray,
  1953.     "Symbol table for use by `intern' and `read'.\n\
  1954. It is a vector whose length ought to be prime for best results.\n\
  1955. The vector's contents don't make sense if examined from Lisp programs;\n\
  1956. to find all the symbols in an obarray, use `mapatoms'.");
  1957.  
  1958.   DEFVAR_LISP ("values", &Vvalues,
  1959.     "List of values of all expressions which were read, evaluated and printed.\n\
  1960. Order is reverse chronological.");
  1961.  
  1962.   DEFVAR_LISP ("standard-input", &Vstandard_input,
  1963.     "Stream for read to get input from.\n\
  1964. See documentation of `read' for possible values.");
  1965.   Vstandard_input = Qt;
  1966.  
  1967.   DEFVAR_LISP ("load-path", &Vload_path,
  1968.     "*List of directories to search for files to load.\n\
  1969. Each element is a string (directory name) or nil (try default directory).\n\
  1970. Initialized based on EMACSLOADPATH environment variable, if any,\n\
  1971. otherwise to default specified by file `paths.h' when Emacs was built.");
  1972.  
  1973.   DEFVAR_BOOL ("load-in-progress", &load_in_progress,
  1974.     "Non-nil iff inside of `load'.");
  1975.  
  1976.   DEFVAR_LISP ("after-load-alist", &Vafter_load_alist,
  1977.     "An alist of expressions to be evalled when particular files are loaded.\n\
  1978. Each element looks like (FILENAME FORMS...).\n\
  1979. When `load' is run and the file-name argument is FILENAME,\n\
  1980. the FORMS in the corresponding element are executed at the end of loading.\n\n\
  1981. FILENAME must match exactly!  Normally FILENAME is the name of a library,\n\
  1982. with no directory specified, since that is how `load' is normally called.\n\
  1983. An error in FORMS does not undo the load,\n\
  1984. but does prevent execution of the rest of the FORMS.");
  1985.   Vafter_load_alist = Qnil;
  1986.  
  1987.   DEFVAR_LISP ("load-history", &Vload_history,
  1988.     "Alist mapping source file names to symbols and features.\n\
  1989. Each alist element is a list that starts with a file name,\n\
  1990. except for one element (optional) that starts with nil and describes\n\
  1991. definitions evaluated from buffers not visiting files.\n\
  1992. The remaining elements of each list are symbols defined as functions\n\
  1993. or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
  1994.   Vload_history = Qnil;
  1995.  
  1996.   DEFVAR_LISP ("current-load-list", &Vcurrent_load_list,
  1997.     "Used for internal purposes by `load'.");
  1998.   Vcurrent_load_list = Qnil;
  1999.  
  2000.   load_descriptor_list = Qnil;
  2001.   staticpro (&load_descriptor_list);
  2002.  
  2003.   Qcurrent_load_list = intern ("current-load-list");
  2004.   staticpro (&Qcurrent_load_list);
  2005.  
  2006.   Qstandard_input = intern ("standard-input");
  2007.   staticpro (&Qstandard_input);
  2008.  
  2009.   Qread_char = intern ("read-char");
  2010.   staticpro (&Qread_char);
  2011.  
  2012.   Qget_file_char = intern ("get-file-char");
  2013.   staticpro (&Qget_file_char);
  2014.  
  2015.   Qascii_character = intern ("ascii-character");
  2016.   staticpro (&Qascii_character);
  2017.  
  2018.   Qload = intern ("load");
  2019.   staticpro (&Qload);
  2020. }
  2021.